package org.learn.java.reflect;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.learn.java.annotation.MyAnnotation;

public class MyReflectTest {
	private static Method[] methods=null;
	private static Method[] primethods=null;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*Class cl = MyReflect.class;
		methods =getMethods(cl, 1);
		printMethodName(methods);*/
		int a =5;
		int b = 25;
		int c =b%a;
		System.out.println(c);
	}

	
	/**
	 * 运行时获取方法
	 * @param cl
	 * @param type
	 * @return
	 */
	public static Method[] getMethods(Class cl,int type){
		Method[] methods=null;
		if(1==type){
			methods=cl.getMethods();
		}else{
			methods=cl.getDeclaredMethods();
		}
		return methods;
	}
	
	public static void printMethodName(Method[] methods){
		for (Method method : methods) {
			System.out.println("methodName:"+method.getName());
		}
	}
	public static Class getMyClassByPath(String path){
		Class<?> clzz = null;
		try {
			clzz = Class.forName(path);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return clzz;
	}
	
	public static void getConstroctors(Class<?> clazz ){
		Constructor<?>[] constructors = clazz.getConstructors();
		Constructor constructor = constructors[0];
	}
}
